/*============================================================================*/
/*                   CONTINENTAL AUTOMOTIVE SYSTEMS                           */
/*============================================================================*/
/*                        OBJECT SPECIFICATION                                */
/*============================================================================*
* name:            HALDebouncer.c
* version:         1.1
* created_by:      Lizette Acosta/Rodrigo Casados
* date_created:    June 22 2013
*=============================================================================*/
/* DESCRIPTION : Debouncer and Button Event Validation                        */
/*============================================================================*/
/* FUNCTION COMMENT : main function of Window Lifter                          */
/*                                                                            */
/*============================================================================*/
/*                               OBJECT HISTORY                               */
/*============================================================================*/
/*  REVISION |   DATE      |                               |      AUTHOR      */
/*----------------------------------------------------------------------------*/
/*  1.1      | 22/June/2013 |                              | Lizette Acosta   */
/*                                                           Rodrigo Casados  */
/*============================================================================*/
#include "stdtypedef.h"
#include "HALDebouncer.h"


/*============================================================================*/
/*                           vfn_ReadButtons                                  */
/*============================================================================*/
void vfn_ReadButtons(T_UBYTE * ptr_ButtonID)
{	
	if(BTN_1 || BTN_2 || BTN_3 || BTN_4)
	{
		if (BTN_1)
		{
			*ptr_ButtonID = 1;
		}
		
		else if(BTN_2)
		{
			*ptr_ButtonID = 2;
		}
		
		else if(BTN_3)
		{
			*ptr_ButtonID = 3;
		}
		
		else if(BTN_4)
		{
			*ptr_ButtonID = 4;
		}
		
	}	
}

/*

/*============================================================================*/
/*                              u8fn_Deboouncer                               */
/*============================================================================*/
	
/*T_UBYTE u8fn_Deboouncer(T_UBYTE * ptr_to_ButtonID)
{
	static T_UWORD u16_Cnt;
	static T_UBYTE u8_PrevButtonID = 0;
	T_UBYTE u8_ValidEvent;
	
	if(u8_PrevButtonID == *ptr_to_ButtonID)		/* Determines if the same button is being pressed. */
/*	{     									/* If it's not the same one, the counter resets.   */
/*     	if((u16_Cnt++) == DELAY_DEBAUNCER)
/*     	{
/*			 u16_Cnt = 0;					/* The counter is set to 0 for further debouncings.*/
/*			 u8_ValidEvent = 1;				/* After 10ms, the event is considered valid.	   */
/*			 u8_PrevButtonID = 0;			/* Invalid Button ID for further comparations.     */
  /*  	}
    	
    	else
    	{
    		u8_ValidEvent = 0;
    	}
	}

	else
	{
		u16_Cnt = 0;
		u8_ValidEvent = 0;
	}
	
	u8_PrevButtonID = (T_UBYTE)(*ptr_to_ButtonID);
	
	return u8_ValidEvent;
}
	
	
	*/
